package cn.pop.hsp_system_v2.Controller;

import cn.pop.hsp_system_v2.Pojo.OutPatient;
import cn.pop.hsp_system_v2.Service.IPatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpSession;
import java.util.Collection;

@Controller

public class hrefController {
    @Autowired
    private IPatientService iPatientService;

    @GetMapping("/")
    public String login(){
        return "login";
    }

    @GetMapping("/register")
    public String register(){
        return "register";
    }

    @GetMapping("/department")
    public String department(Model model){
        Collection<OutPatient> outPatients= iPatientService.selectAllOutPatient();
        System.out.println(outPatients);
        model.addAttribute("outpatients",outPatients);
        return "patient/department";
    }

    @GetMapping("/loginOut")
    public String loginOut(HttpSession session){
        session.invalidate();
        return "/login";
    }

//    @GetMapping("/userCenter")
//    public String appointment(){
//        return "/appointment";
//    }

//    //后台页面跳转
//    @GetMapping("/manager/index")
//    public String index(Model model){
//        int count = tbDocInfoService.count();
//        model.addAttribute("Doc_count", count);
//        return "manager/manager_index";
//    }
//    //材料入库跳转
//    @GetMapping("/manager/warehousing")
//    public String warehousing(){
//        return "/manager/WareHousing";
//    }
//    //材料审批跳转
//    @GetMapping("/manager/approve")
//    public String approve(){
//        return "/manager/approve";
//    }
//
//    //材料信息
//    @Autowired
//    private TbUseService tbUseService;
//    @Autowired
//    private TbUsetypeService tbUsetypeService;
//    @GetMapping("/manager/warehousingInfo")
//    public String warehousingInfo(Model model,@RequestParam(value="page",defaultValue="1")Integer page,String search_useName, Integer search_typeid, String search_business, Integer search_number){
//        if(search_useName!=null|search_typeid!=null|search_business!=null|search_useName!=null){
//            QueryWrapper<TbUse> qw=new QueryWrapper<>();
//            qw.like(search_useName!=null, "use_name",search_useName );
//            qw.eq(search_typeid!=null, "typeid", search_typeid);
//            qw.like(search_business!=null, "business",search_business );
//            qw.eq(search_number!=null, "number", search_number);
//            IPage<TbUse> useIPage=tbUseService.selectPageLike(new Page<>(page,10), qw);
//            List<TbUse> useList = useIPage.getRecords();
//            List<TbUsetype> tbUsetypes=tbUsetypeService.list();
//            model.addAttribute("useList", useList);
//            model.addAttribute("IPage", useIPage);
//            model.addAttribute("usetype",tbUsetypes);
//            return "/manager/WareHousingInfo";
//        }else {
//            IPage<TbUse> useIPage = tbUseService.selectPage(new Page<>(page, 10));
//            List<TbUse> useList = useIPage.getRecords();
//            List<TbUsetype> tbUsetypes = tbUsetypeService.list();
//            model.addAttribute("useList", useList);
//            model.addAttribute("IPage", useIPage);
//            model.addAttribute("usetype", tbUsetypes);
//            return "/manager/WareHousingInfo";
//        }
//    }
//    //医生信息管理
//    @Autowired
//    private TbDocInfoService tbDocInfoService;
//    @GetMapping("/manager/doctorInfo")
//    public String doctorInfo(Model model,@RequestParam(value="page",defaultValue="1")Integer page,
//                             String search_id,String search_name,String search_phone){
//        if(search_id!=null|search_name!=null|search_phone!=null){
//            QueryWrapper<TbDocInfo> qw=new QueryWrapper<>();
//            qw.like(StringUtils.isEmpty(search_id), "id", search_id);
//            qw.like(StringUtils.isEmpty(search_name), "name", search_name);
//            qw.likeRight(StringUtils.isEmpty(search_phone), "phone", search_phone);
//            IPage<TbDocInfo> docInfoIPage = tbDocInfoService.selectPageLike(new Page<>(page, 5),qw);
//            System.out.println(docInfoIPage);
//            List<TbDocInfo> doclist=docInfoIPage.getRecords();
//            System.out.println(doclist);
//            model.addAttribute("docInfo", doclist);
//            model.addAttribute("IPage", docInfoIPage);
//            return "/manager/doctorInfo";
//        }else {
//            IPage<TbDocInfo> docInfoIPage = tbDocInfoService.selectPage(new Page<>(page, 10));
//            List<TbDocInfo> doclist = docInfoIPage.getRecords();
//            model.addAttribute("docInfo", doclist);
//            model.addAttribute("IPage", docInfoIPage);
//            System.out.println(doclist);
//            return "/manager/doctorInfo";
//        }
//    }
//    //账单统计
//    @Autowired
//    private TbAccountsService tbAccountsService;
//    @GetMapping("/manager/bills")
//    public String bills(Model model,@RequestParam(value="page",defaultValue="1")Integer page){
//        QueryWrapper<TbAccounts> queryWrapper=new QueryWrapper<>();
//        queryWrapper.eq("status", 1);
//        IPage<TbAccounts> tbAccountsIPage = tbAccountsService.selectAccounts(new Page<>(page, 10),queryWrapper);
//        List<TbAccounts> accountsList=tbAccountsIPage.getRecords();
//        List<TbUse> uselist = tbUseService.list();
//
//        model.addAttribute("uselist", uselist);
//        model.addAttribute("accountslist",accountsList);
//        return "/manager/bills";
//    }

}
